package org.apache.jsp;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.jsp.*;
import org.apache.jackrabbit.util.Text;

public final class local_jsp extends org.apache.jasper.runtime.HttpJspBase
    implements org.apache.jasper.runtime.JspSourceDependent {

  private static final JspFactory _jspxFactory = JspFactory.getDefaultFactory();

  private static java.util.List _jspx_dependants;

  private javax.el.ExpressionFactory _el_expressionfactory;
  private org.apache.AnnotationProcessor _jsp_annotationprocessor;

  public Object getDependants() {
    return _jspx_dependants;
  }

  public void _jspInit() {
    _el_expressionfactory = _jspxFactory.getJspApplicationContext(getServletConfig().getServletContext()).getExpressionFactory();
    _jsp_annotationprocessor = (org.apache.AnnotationProcessor) getServletConfig().getServletContext().getAttribute(org.apache.AnnotationProcessor.class.getName());
  }

  public void _jspDestroy() {
  }

  public void _jspService(HttpServletRequest request, HttpServletResponse response)
        throws java.io.IOException, ServletException {

    PageContext pageContext = null;
    HttpSession session = null;
    ServletContext application = null;
    ServletConfig config = null;
    JspWriter out = null;
    Object page = this;
    JspWriter _jspx_out = null;
    PageContext _jspx_page_context = null;


    try {
      response.setContentType("text/html");
      pageContext = _jspxFactory.getPageContext(this, request, response,
      			null, true, 8192, true);
      _jspx_page_context = pageContext;
      application = pageContext.getServletContext();
      config = pageContext.getServletConfig();
      session = pageContext.getSession();
      out = pageContext.getOut();
      _jspx_out = out;


request.setAttribute("title", "Local Repository Access");

      org.apache.jasper.runtime.JspRuntimeLibrary.include(request, response, "header.jsp", out, false);
      out.write("\r\n");
      out.write("<p>\r\n");
      out.write("  The content repository within this web application can be accessed\r\n");
      out.write("  locally by other web applications within the same servlet container.\r\n");
      out.write("  Local access is much faster than <a href=\"remote.jsp\">remote access</a>.\r\n");
      out.write("</p>\r\n");
      out.write("<p>\r\n");
      out.write("  The content repository is made available both through JNDI and the\r\n");
      out.write("  web application context.\r\n");
      out.write("</p>\r\n");
      out.write("\r\n");
      out.write("<h3>Accessing the repository through JNDI</h3>\r\n");
      out.write("<p>\r\n");
      out.write("  By default the repository is only made available in a dummy JNDI directory\r\n");
      out.write("  local to this web application. However, you can make the repository globally\r\n");
      out.write("  available if your servlet container allows a web application to modify the\r\n");
      out.write("  global JNDI directory or you are using some other JNDI directory that can\r\n");
      out.write("  manage unserializable Java objects.\r\n");
      out.write("</p>\r\n");
      out.write("<p>\r\n");
      out.write("  To bind the the repository to such a JNDI directory, you need to modify\r\n");
      out.write("  the <code>java.naming</code> parameters in either the /WEB-INF/web.xml\r\n");
      out.write("  deployment descriptor or the jackrabbit/bootstrap.properties file. You need\r\n");
      out.write("  to redeploy this web application to activate the changes.\r\n");
      out.write("</p>\r\n");
      out.write("<p>\r\n");
      out.write("  Use the following code to access a repository bound in a JNDI directory:\r\n");
      out.write("</p>\r\n");
      out.write("<pre>\r\n");
      out.write("<b>import</b> javax.jcr.Repository;\r\n");
      out.write("<b>import</b> javax.naming.Context;\r\n");
      out.write("<b>import</b> javax.naming.InitialContext;\r\n");
      out.write("\r\n");
      out.write("Context context = <b>new</b> InitialContext(...);\r\n");
      out.write("Repository repository = (Repository) context.lookup(...);\r\n");
      out.write("</pre>\r\n");
      out.write("\r\n");
      out.write("<h3>Accessing the repository through servlet context</h3>\r\n");
      out.write("<p>\r\n");
      out.write("  This web application makes the repository available as the\r\n");
      out.write("  <code>javax.jcr.Repository</code> attribute in the application context.\r\n");
      out.write("  If your servlet container supports cross-context access, you can\r\n");
      out.write("  access the repository directly using that attribute.\r\n");
      out.write("</p>\r\n");
      out.write("<p>\r\n");
      out.write("  For example in <a href=\"http://tomcat.apache.org/\">Apache Tomcat</a>\r\n");
      out.write("  you can enable cross-context access by setting the <code>crossContext</code>\r\n");
      out.write("  attribute to true in the &lt;Context/&gt; configuration.\r\n");
      out.write("</p>\r\n");
      out.write("<p>\r\n");
      out.write("  Use the following code to access a repository through the servlet context:\r\n");
      out.write("</p>\r\n");
      out.write("<pre>\r\n");
      out.write("<b>import</b> javax.jcr.Repository;\r\n");
      out.write("<b>import</b> javax.servlet.ServletContext;\r\n");
      out.write("\r\n");
      out.write("ServletContext context = ...; // <em>context of your servlet</em>\r\n");
      out.write("ServletContext jackrabbit =\r\n");
      out.write("    context.getContext(\"<em>");
      out.print( Text.encodeIllegalXMLCharacters(request.getContextPath()) );
      out.write("</em>\");\r\n");
      out.write("Repository repository = (Repository)\r\n");
      out.write("    context.getAttribute(Repository.<b>class</b>.getName()).\r\n");
      out.write("</pre>\r\n");
      out.write("\r\n");
      out.write("<h3>Using the jackrabbit-jcr-servlet component</h3>\r\n");
      out.write("<p>\r\n");
      out.write("  The <em>jackrabbit-jcr-servlet</em> component contains utility classes\r\n");
      out.write("  for use within JCR web applications. With that component you can hide\r\n");
      out.write("  both the above and the <a href=\"remote.jsp\">remote access</a> options\r\n");
      out.write("  from your code, and use just the following to access a repository:\r\n");
      out.write("</p>\r\n");
      out.write("<pre>\r\n");
      out.write("<b>import</b> javax.jcr.Repository;\r\n");
      out.write("<b>import</b> org.apache.jackrabbit.servlet.ServletRepository;\r\n");
      out.write("\r\n");
      out.write("<b>public class</b> MyServlet <b>extends</b> HttpServlet {\r\n");
      out.write("\r\n");
      out.write("    <b>private final</b> Repository repository = <b>new</b> ServletRepository(<b>this</b>);\r\n");
      out.write("\r\n");
      out.write("    // ...\r\n");
      out.write("\r\n");
      out.write("}\r\n");
      out.write("</pre>\r\n");
      out.write("<p>\r\n");
      out.write("  See the jackrabbit-jcr-servlet documentation for more details.\r\n");
      out.write("</p>\r\n");
      org.apache.jasper.runtime.JspRuntimeLibrary.include(request, response, "footer.jsp", out, false);
      out.write('\r');
      out.write('\n');
    } catch (Throwable t) {
      if (!(t instanceof SkipPageException)){
        out = _jspx_out;
        if (out != null && out.getBufferSize() != 0)
          try { out.clearBuffer(); } catch (java.io.IOException e) {}
        if (_jspx_page_context != null) _jspx_page_context.handlePageException(t);
      }
    } finally {
      _jspxFactory.releasePageContext(_jspx_page_context);
    }
  }
}
